<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<base href="<%=request.getContextPath() %>/">
<link rel="stylesheet" href="layui/css/layui.css"  media="all">
<script src="layui/layui.all.js" charset="utf-8"></script>

<div>
	<div id="test"></div>
</div>

<script>
$(function(){
	commentStar(0);
});

//将评价星星封装到函数内
function commentStar(value){
	layui.use(['rate'], function(){
		  var rate = layui.rate;
			//自定义文本
			rate.render({
			  elem: '#test',
			  value: value,
			  text: true,
			  setText: function(value){ //自定义文本的回调
			    var arrs = {
				  '0': '请选择您的评价！',  
			      '1': '差',
			      '2': '一般',
			      '3': '中等',
			      '4': '好',
			      '5': '极好'
			    };
			  	this.span.text(arrs[value] || ( value + "星"));
			  }
			})
		});
}

</script>

